﻿/**
 * 设备配置列表
 */

class AddEquipment extends UiFramework.UiAbstract
{
    onStart(divSelf: HTMLDivElement)
        {

            // 头部 div
            let headDiv = document.createElement("div");
            headDiv.style.width = "100%";
            headDiv.style.height = "46px";
            headDiv.style.lineHeight = "45px";
            headDiv.style.overflow = "hidden";
            this.divSelf.appendChild(headDiv);

            // 头部 title
            let tit = document.createElement("tit");
            tit.textContent = "设备配置列表";
            tit.className = "configurationDetailTit";
            headDiv.appendChild(tit);

            // 头部返回按钮
            let btnReturn = document.createElement("img");
            btnReturn.src = "picture/return.png";
            btnReturn.style.height = "2%";
            btnReturn.className = "configurationDetailReturn";
            headDiv.appendChild(btnReturn);

            // 头部右上角全部设备按钮
            let btnHead = document.createElement("input");
            btnHead.type = "button";
            btnHead.value = "全部设备";
            btnHead.className = "rightTopWhiteButton";
            headDiv.appendChild(btnHead);

            let equipments = new Array("空调", "灯", "摄像头", "插座"); // 动态数组

            // 列表 item 
            for (let i = 0; i < 4; i++)
            {
                // 条目 div
                let divItem = document.createElement("div");
                divItem.style.width = "100%";
                divItem.style.height = "66px";
                divItem.style.borderBottom = '2px solid #95989A';
                this.divSelf.appendChild(divItem);

                // 条目名称前图标
                let imgItem = document.createElement("img");
                imgItem.src = "picture/ic_dialog.png";
                imgItem.style.paddingTop = "24px";
                imgItem.style.paddingLeft = "30px";
                divItem.appendChild(imgItem);

                // 条目名称
                let nameItem = document.createElement("nameItem");
                nameItem.style.paddingLeft = "20px";
                nameItem.textContent = equipments[i]; // 填充内容
                divItem.appendChild(nameItem);

                // 条目右箭头
                let rightArrow = document.createElement("img");
                rightArrow.src = "picture/ic_arrow_right.png";
                rightArrow.style.paddingTop = "24px";
                rightArrow.style.cssFloat = "right"; // 设置距离右边距离
                rightArrow.style.marginRight = "20px";
                divItem.appendChild(rightArrow);
            }

            //点击出现弹窗
            btnHead.onclick = () => {
                this.openDialog("notBindEquipDialog");
            }
            


            //点击返回按钮
            btnReturn.onclick = () => {
                this.finish();
            }

        }


    onEnd() {

    }
}

UiMap["addEquipment"] = () =>
{
    return new AddEquipment();
}